package com.cheerscpl.redis;

import com.cheerscpl.utils.SpringContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Created by chenpuliang on 2017/5/11.
 */
public class JedisClient {

    private static final Logger logger = LoggerFactory.getLogger(JedisClient.class);

    private static RedisTemplate redisTemplate;

    static{
        redisTemplate = (RedisTemplate) SpringContextUtil.getInstance().getBean("redisTemplate");
    }

    public static RedisTemplate getRedisTemplate(){
        return redisTemplate;
    }

    public static void publish(String channel, String message){
        redisTemplate.convertAndSend(channel, message);
        logger.debug("public channel {}, success.", channel);
    }
}
